import React, { useState } from "react";
import Son from "./Son";

const Father = () => {
  const [fatherData, setFatherData] = useState();
  const onFather = data => {
    setFatherData(data);
  };

  return (
    <div className="App">
      <h1>父子组件通信</h1>
      <h2>我是父组件</h2>
      <p>子传父，通过回调函数传值</p>
      <div>{fatherData}</div>
      <hr />
      <Son onFather={onFather}></Son>
    </div>
  );
};

export default Father;
